/******************************************************************
 * Title: scrunch.sc
 * Author:  Brian Peck
 * Date: Spring 2011
 * Description: Specification model for scrunch (in DES)
 *****************************************************************/
#include <stdio.h>
import "i_receiver";
import "i_sender";

behavior desScrunch(i_receiver ir, i_sender is)
{
  const char* bName = "desScrunch";
  void main(void) {
    
    unsigned char outof;
    unsigned long into [2];
    unsigned long temp=0;
    int i, j;
    
   while(1) {
    for (i=0; i<2; i++)
    { 
       for (j=0; j<4; j++) 
       {
          ir.receive(&outof, sizeof(char));
          temp |= outof << (8*(3-j));
          
        }
       into[i] = temp; 
     }       
      
      printf("%s: Sending block[0]: 0x%lx, block[2]: 0x%lx\n", bName, into[0], into[1]);

      is.send(&into[0], sizeof(unsigned long));
      is.send(&into[1], sizeof(unsigned long));
    }
    
   } // end main
};// end behavior scrunch

